package boot3.mapper;

import boot3.pojo.Application;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ApplicationMapper {
    // 插入一个申请
    @Insert("insert application value(#{projectapply_id},#{project_id},#{student_id},#{student_name},#{apply_time}," +
            "#{apply_state},#{project_name})")
    public Boolean addApplication(Application application);
    // 查找所有的申请
    @Select("select * from application")
    public List<Application> selectAllApplication();
    //根据学生的ID和查找这个学生所有的申请
    @Select("select * from application where student_id=#{student_id}")
    public List<Application> selectApplicationByStudentId(String student_id);
    //根据项目的ID获取申请列表
    @Select("select * from application where project_id=#{project_id}")
    public List<Application> selectApplicationByProjectId(String project_id);
    //根据项目的ID更新申请状态为：同意
    @Update("update application set apply_state='同意' where projectapply_id=#{application_id}")
    public Boolean updateApplicationState(String application_id);
    //更新项目状态为结束
    @Update("update application set apply_state='结束' where project_id=#{project_id}")
    public Boolean updateApplicationStateOver(String project_id);
}
